#include "TextureFactory.h"
#include "ValidationUtils.h"
#include "FileNotFoundException.h"

TextureFactory::TextureFactory(void)
{
}

TextureFactory::~TextureFactory(void)
{
}

Element * TextureFactory::createElement( XMLElement* element)
{
	return this->createTexture(element);
}

Texture * TextureFactory::createTexture( XMLElement* element)
{
	Texture * ptrTexture = new Texture();
	
	ptrTexture->setId(element->getAttributeByName("id")->getValue()->c_str());

	string path = *(element->getAttributeByName("path")->getValue());
	if(!ValidationUtils::fileExists(path))
	{
		throw FileNotFoundException("El archivo de textura '"+path+"' no existe.");
	}
	ptrTexture->setPath(path);

	return ptrTexture;
}